package com.geticsen.leetcode;

//https://leetcode-cn.com/problems/symmetric-tree/submissions/
public class Solution_101 {
    public boolean isSymmetric(TreeNode root) {
        return symmetric(root.left, root.right);
    }

    public boolean symmetric(TreeNode left, TreeNode right) {
        if (left == null && right == null) {
            return true;
        }
        //如果左边和右边不相等就直接返回false
        if (left != null && right != null) {
            if (left.val != right.val) {
                return false;
            }
            return symmetric(left.left, right.right) && symmetric(left.right, right.left);
        }
        return false;
    }
}
